<?php

//Error Checking function when running queries in MYSQL

function dbquery($q)
{	
  $r=mysql_query($q);
  if(!$r){
    die("Error in query $q: <br/>" . mysql_error());
  }
  return $r;
}

//Login to a MYSQL DB and open up a DB for the script to use

function connectSQLServer($user, $pass, $db){
  $pwdb = mysql_connect("localhost:3306", $user,$pass);	
  
  //If the password is not correct, else it is correct

  if(!$pwdb){
    die('Could not connect: '.mysql_error());
  } else {
    mysql_select_db($db, $pwdb);
  }
  return $pwdb;	 
}
//Cleans data based on if magic quotes is on or off
function bypassMQInput($name){
  
  //If magic quotes is on else not
  
  if(get_magic_quotes_gpc()){
    return stripslashes($name);
  } else {
    return $name;
  }
}

//Prints header and user specific left sidebar with navigation links
function print_header($pos, $page){
?>
<html>
  <head>
    <link rel="stylesheet" href="/TEAMSCI/phys_files_standard.css" ... />
    <title>PHYS-FILES</title>
  </head>
  <body>
    <div id="header">
      <h1>PHYS-FILES</h1>
    </div>
    <div class="wrapper">
      <div id="content">
        <div id="sidebar">
	   <div id="menu">
	     <h2 class="heading">Menu Options</h2>
	       <ul>
<?php

  //If $pos == 1 => Admin, $pos == 2 => Lead Researcher, $pos == 3 => Lead Researcher
  

  if($pos == 1){

    //Highlight the current link based on what page is being viewed

    if($page == 1){
      ?>
      <li class="active"><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 2){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li class="active"><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 3){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li class="active"><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 4){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li class="active"><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 5){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li class="active"><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 100){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UserPerm.php" title="account">Manage User Permissions</a></li>
      <li><a href="/TEAMSCI/UserPend.php" title="upload">Pending User Approval</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="search">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/Preapprove.php" title="suggest">Preapprove Email for Use</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 101){
      ?>
      <li><a href="/TEAMSCI/index.php" title="homepage">Homepage</a></li>
      <?php
    } else if($page == 105){
      ?>
      <li><a href="/TEAMSCI/index.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/newUser.php" title="register">New User Registration</a></li>
      <?php
    }

  } else if($pos == 2){
    
    if($page == 1){
      ?>
      <li  class="active"><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 4){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li class="active"><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 6){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li class="active"><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 7){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li class="active"><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 8){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li class="active"><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 9){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li class="active"><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 100){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/ApproveFile.php" title="suggest">Approve File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    }
  } else if($pos == 3) {
if($page == 1){
      ?>
      <li  class="active"><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 6){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li class="active"><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 7){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li class="active"><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 8){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li class="active"><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 9){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li class="active"><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    } else if($page == 100){
      ?>
      <li><a href="/TEAMSCI/members.php" title="homepage">Homepage</a></li>
      <li><a href="/TEAMSCI/UpFile.php" title="account">Upload a File</a></li>
      <li><a href="/TEAMSCI/SearchFile.php" title="upload">Search for a File</a></li>
      <li><a href="/TEAMSCI/SuggestFile.php" title="search">Suggest File for Public Use</a></li>
      <li><a href="/TEAMSCI/AccountInfo.php" title="suggest">My account</a></li>
      <li><a href="/TEAMSCI/Logout.php" title ="logout">Logout</a></li>
      <?php
    }

  }
  ?>
  </ul>
  </div>
  </div>
  <div id="mainpanel">
  <div class="main">

  <?php
}


//Print footer of website
function print_footer(){
  ?>
  </div>
  </div>
  </div>				
  <div class="push"></div>
  </div>
  <div class="footer">
  <p>Copyright &copy; 2009</strong></a></p>
  </div>
  </body>
  </html>
  <?php
}
?>
